package com.zoe.app.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @author Zoe.Zhang
 * @date 2021/09/25
 * @description https://blog.csdn.net/kehonghg/article/details/81180731
 * * 继承WebMvcConfigurationSupport会发现Spring Boot的WebMvc自动配置失效(WebMvcAutoConfiguration自动化配置),尽量使用WebMvcConfigurer
 */
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {
    /**
     * Override this method to add resource handlers for serving static resources.
     *
     * @param registry
     * @see ResourceHandlerRegistry
     */
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 表示拦截所有profile的请求地址,代理到本地D:/home/upload/这个磁盘路径下
        registry.addResourceHandler("/profile/**").addResourceLocations("file:D:/home/upload/");
    }
}
